/**
 * @file    inf_bts7020.h
 * @author  yhy
 * @brief   高策开关接口层
 * @version 1.00
 * @date    2025-07-19
 *
 * @copyright Copyright (c) 2025
 *
 */
#ifndef __INF_BTS7020_H__
#define __INF_BTS7020_H__

#include "common_config.h"

#include <stdbool.h>
#include <stdint.h>

#define BTS7020_VALVE_EN_PIN_NUM GET_PIN_NUM(E, 8)
#define BTS7020_PUMP_EN_PIN_NUM  GET_PIN_NUM(E, 3)
#define BTS7020_PV_DSEL_PIN_NUM  GET_PIN_NUM(B, 4)
#define BTS7020_FANL_PIN_NUM     GET_PIN_NUM(B, 13)
#define BTS7020_FANR_PIN_NUM     GET_PIN_NUM(D, 4)
#define BTS7020_FAN_DSEL_PIN_NUM GET_PIN_NUM(A, 3)

/**
 * @brief BTS7020设备枚举
 *
 */
typedef enum
{
    BTS7020_DEVICE_PUMP_VALVE = 0U,
    BTS7020_DEVICE_FAN        = 1U,
    BTS7020_DEVICE_MAX,
} bts7020_device_e;

/**
 * @brief BTS7020输入枚举
 *
 */
typedef enum
{
    BTS7020_IN0 = 0U,
    BTS7020_IN1 = 1U,
    BTS7020_IN_MAX,
} bts7020_in_e;

/**
 * @brief BTS7020高策开关
 *
 */
typedef struct
{
    bool    in0_en;                     /*!< 输入0使能 */
    bool    in1_en;                     /*!< 输入1使能 */
    int32_t ad_val_buf[BTS7020_IN_MAX]; /* 采集到的adc值 */
    uint8_t dsel;                       /* is选择通道, 低电平(0)时选择in0, 高电平时选择in1(1) */
} bts7020_t;

extern bts7020_t bts7020_list[BTS7020_DEVICE_MAX];

result_e inf_bts7020_init(void);
result_e inf_bts7020_set_switch(bts7020_device_e device, bts7020_in_e input, bool enable);

#endif
